/**
 * Created by jackliu on 15/12/16.
 */

var common = require('../../common');
var pool = require('../index');
var mysql = require('mysql');
var ItbBaseModel = require('./ItbBaseModel');
var async  = require( 'async'); // 同步控制


// Schema 结构
var ItbPageModel = function(obj){
    ItbBaseModel.call(this,obj);

  // 以下为表定义数据，需要的字段就填入
  // `page_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '文档页ID',
  //`doc_id` bigint(20) unsigned NOT NULL COMMENT '模板／文档ID',
  //`base_page_id` bigint(20) unsigned DEFAULT NULL COMMENT '模版页ID（用户数据用）',
  //`page_index` int(3) NOT NULL DEFAULT '0' COMMENT '页下标（0开始）',
  //`user_type` int(1) NOT NULL DEFAULT '0' COMMENT '0后台; 1用户',
  //`data` mediumtext COMMENT '模版页内容',
  //`replaces` mediumtext COMMENT '可替换组',
  //`thumb_s` text COMMENT '缩略图小［json数组字符串］',
  //`thumb_m` text COMMENT '缩略图中',
  //`thumb_l` text COMMENT '缩略图大',
  //`create_time` datetime NOT NULL,
  //`update_time` datetime NOT NULL,
  //`update_by` varchar(50) NOT NULL DEFAULT '',
  //`del_flg` int(1) NOT NULL DEFAULT '0',

};
ItbPageModel.prototype = new ItbBaseModel();

// 取得表名
ItbPageModel.prototype.getTableName = function(){
    return 'itb_page';
}
// 取得查询语句中where 后面匹配主键的条件（需要各派生类进行重载）
ItbPageModel.prototype.getWhereConditionOfKeyEqual = function(){
    return 'page_id='+this.page_id;
}

// 根据文档id逻辑删除对应pages
ItbPageModel.prototype.deletePagesByDocIdLogic = function(callback){
    var THIS = this;
    var tableName = this.getTableName();

    pool.pool.getConnection(function(err, connection) {
        // Use the connection
        var sql = 'UPDATE '+tableName+' SET del_flg=1, update_time=sysdate(), update_by=? WHERE doc_id=? AND del_flg=0 ';
        var sqlValue = [THIS.update_by, THIS.doc_id];
        var sql = mysql.format(sql, sqlValue);
        console.log(sql);
        connection.query(sql, function(error, result) {
            // And done with the connection.
            connection.release();

            console.log();

            if(error) {
                callback(error);
            } else {
                callback(null);
            }
        });
    });
}

//------------------------------------------------------------------
/* 根据文档id(多个时逗号连接)获取pages信息,
注意:需要初始化 doc_ids 作为文档id
* 不关联document表
* 参数:callback:回调，参数
*          error:错误,null表示无错误
*          pageModels:页面数据数组,每个元素为：
*                  ItbPageModel结构
*/
ItbPageModel.prototype.getPagesInfoByDocIds = function(callback){
    var THIS = this;
    var tableName = this.getTableName();

    pool.pool.getConnection(function(err, connection) {
        if (err) {
            console.log('ItbPageModel.getPagesInfoByDocIds Err:'+err);
        }
        // Use the connection
        var sql = 'SELECT * FROM itb_page t WHERE t.del_flg = 0 AND t.doc_id IN ( ' +
            THIS.doc_ids +
            ' ) ORDER BY t.doc_id, t.page_index ';
        //var sqlValue = [];
        //var sql = mysql.format(sql, sqlValue);
        console.log(sql);
        connection.query(sql, function(error, result) {
            // And done with the connection.
            connection.release();

            console.log();

            callback(error, result);
        });
    });
}

//------------------------------------------------------------------
/* 根据文档获取所有模版pages信息,
 * 参数:callback:回调，参数
 *          error:错误,null表示无错误
 *          pageModels:页面数据数组,每个元素为：
 *                  ItbPageModel结构
 */
ItbPageModel.prototype.getTemplatePagesCount = function(callback){
    var THIS = this;
    var tableName = this.getTableName();

    pool.pool.getConnection(function(err, connection) {
        if (err) {
            console.log('ItbPageModel.getTemplatePagesCount Err:'+err);
        }
        // Use the connection
        var sql = 'select count(*) as itemCount from itb_page p where p.del_flg=0 and p.doc_id in('
            +           ' select d.doc_id from itb_document d where d.`base_doc_id` is null and d.del_flg=0 '
            +  ')';
        var sqlValue = [];
        var sql = mysql.format(sql, sqlValue);
        console.log(sql);


        //var sqlValue = [];
        //var sql = mysql.format(sql, sqlValue);
        console.log(sql);
        connection.query(sql, function(error, items) {
            // And done with the connection.
            connection.release();

            var total=0;
            if(error) {
                console.log(error);
            } else if (items) {
                console.log('find item');
                total = items[0].itemCount;
            } else{
                console.log('find no one');
            }

            callback(error, total);
        });
    });
}
ItbPageModel.prototype.getTemplatePages = function(callback, skipCnt, pageSize){
    var THIS = this;
    var tableName = this.getTableName();

    pool.pool.getConnection(function(err, connection) {
        if (err) {
            console.log('ItbPageModel.getTemplatePages Err:'+err);
        }
        // Use the connection
        var sql = 'select * from itb_page p where p.del_flg=0 and p.doc_id in('
            +           'select d.doc_id from itb_document d where d.`base_doc_id` is null and d.del_flg=0'
            +  ')';

        if(typeof skipCnt!='undefined' && skipCnt != null && typeof pageSize!='undefined' && pageSize != null){
            sql += " limit " + Number(skipCnt) + "," + Number(pageSize);
        }

        //var sqlValue = [];
        //var sql = mysql.format(sql, sqlValue);
        console.log(sql);
        connection.query(sql, function(error, result) {
            // And done with the connection.
            connection.release();

            console.log();

            callback(error, result);
        });
    });
}

//------------------------------------------------------------------
/* 根据文档页id(多个时逗号连接)获取pages信息,
 注意:需要初始化 page_ids 作为文档页id
 * 不关联document表
 * 参数:callback:回调，参数
 *          error:错误,null表示无错误
 *          pageModels:页面数据数组,每个元素为：
 *                  ItbPageModel结构
 */
ItbPageModel.prototype.getPagesInfoByPageIds = function(callback){
    var THIS = this;
    var tableName = this.getTableName();

    pool.pool.getConnection(function(err, connection) {
        if (err) {
            console.log('ItbPageModel.getPagesInfoByPageIds Err:'+err);
        }
        // Use the connection
        var sql = 'SELECT * FROM itb_page t WHERE t.del_flg = 0 AND t.page_id IN ( ' +
            THIS.page_ids +
            ' ) ORDER BY t.doc_id, t.page_index ';
        //var sqlValue = [];
        //var sql = mysql.format(sql, sqlValue);
        console.log(sql);
        connection.query(sql, function(error, result) {
            // And done with the connection.
            connection.release();

            console.log();

            callback(error, result);
        });
    });
}

//------------------------------------------------------------------
/* 根据文档页id更新audio,video信息(可多页更新)
 注意:需要初始化 pages_media =
             [{
             base_page_id: 122, // 对应后端的page_id
             audio: [{url: xxx, duration: 10}], // 数组(url,时长)
             video: [] // url数组
             }]
 */
ItbPageModel.prototype.updatePagesMediaInfo = function(callback){
    var THIS = this;
    var arrData = THIS.pages_media;

    pool.pool.getConnection(function(err, connection) {
        var asyncFuncs = [];
        for (var i in arrData) {

            asyncFuncs.push((function (index, data) {
                return function (asyncCallback) {
                    var sql = null;
                    var param = null;

                    if (THIS.flag == "1") {
                        sql = " UPDATE ITB_PAGE SET update_time=sysdate(), update_by=?, audio=? WHERE page_id=? ";
                        param = [THIS.update_by, JSON.stringify(data.audio||[]), data.base_page_id];

                    } else if (THIS.flag == "2") {
                        sql = " UPDATE ITB_PAGE SET update_time=sysdate(), update_by=?, video=? WHERE page_id=? ";
                        param = [THIS.update_by, JSON.stringify(data.video||[]), data.base_page_id];

                    } else if (THIS.flag == "3") {
                        sql = " UPDATE ITB_PAGE SET update_time=sysdate(), update_by=?, media=? WHERE page_id=? ";
                        param = [THIS.update_by, JSON.stringify(data.media||[]), data.base_page_id];

                    } else {
                        sql = " UPDATE ITB_PAGE SET update_time=sysdate(), update_by=?, audio=?, video=?, media=? WHERE page_id=? ";
                        param = [THIS.update_by, JSON.stringify(data.audio||[]), JSON.stringify(data.video||[]), JSON.stringify(data.media||[]), data.base_page_id];
                    }

                    var exeSql = mysql.format(sql, param);
                    console.log(exeSql);
                    connection.query(exeSql, function (error, result) {

                        if (error) {
                            console.log('ItbPageModel.js [updatePagesMediaInfo] update error: ' + error);
                        }

                        asyncCallback(error, result);
                    });
                }
            })(i, arrData[i])); // 利用闭包解决动态参数传递问题
        }
        async.parallel(asyncFuncs, function (err, results) {

            // And done with the connection.
            connection.release();

            callback(err, results);
        });
    });
}
//------------------------------------------------------------------
/* 根据文档页id更新audio,video信息(单页更新)
 注意:需要初始化 pages_media =
 [{
 base_page_id: 122, // 对应后端的page_id
 audio: [{url: xxx, duration: 10}], // 数组(url,时长)
 video: [] // url数组
 }]
 */
ItbPageModel.prototype.updatePageMediaInfo = function(callback){
    var THIS = this;
    var data = THIS.page_media;

    pool.pool.getConnection(function(err, connection) {
        var sql = null;
        var param = null;

        if (THIS.flag == "1") {
            sql = " UPDATE ITB_PAGE SET update_time=sysdate(), update_by=?, audio=? WHERE page_id=? ";
            param = [THIS.update_by, JSON.stringify(data.audio||[]), data.base_page_id];

        } else if (THIS.flag == "2") {
            sql = " UPDATE ITB_PAGE SET update_time=sysdate(), update_by=?, video=? WHERE page_id=? ";
            param = [THIS.update_by, JSON.stringify(data.video||[]), data.base_page_id];

        } else if (THIS.flag == "3") {
            sql = " UPDATE ITB_PAGE SET update_time=sysdate(), update_by=?, media=? WHERE page_id=? ";
            param = [THIS.update_by, JSON.stringify(data.media||[]), data.base_page_id];

        } else {
            sql = " UPDATE ITB_PAGE SET update_time=sysdate(), update_by=?, audio=?, video=?, media=? WHERE page_id=? ";
            param = [THIS.update_by, JSON.stringify(data.audio||[]), JSON.stringify(data.video||[]), JSON.stringify(data.media||[]), data.base_page_id];
        }

        var exeSql = mysql.format(sql, param);
        console.log(exeSql);
        connection.query(exeSql, function (error, result) {

            if (error) {
                console.log('ItbPageModel.js [updatePageMediaInfo] update error: ' + error);
            }

            connection.release();

            callback(error, result);
        });
    });
}

//------------------------------------------------------------------
/* 根据文档id清除audio,video信息
 */
ItbPageModel.prototype.clearPagesMediaInfo = function(callback){
    var THIS = this;
    var tableName = this.getTableName();

    pool.pool.getConnection(function(err, connection) {
        // Use the connection
        var sql = 'UPDATE itb_page SET audio=null, video=null, update_time=sysdate(), update_by=? WHERE doc_id=? ';
        var sqlValue = [THIS.update_by, THIS.doc_id];
        var sql = mysql.format(sql, sqlValue);
        console.log(sql);
        connection.query(sql, function(error, result) {
            // And done with the connection.
            connection.release();

            console.log();

            callback(error, result);
        });
    });
}

//------------------------------------------------------------------
// arrReplaceData: JSON字符串数组
/**
 * 批量新规pages
 * @param callback
 * @param doc_id
 * @param user_type
 * @param user_id
 * @param arrPageJson:
 *       pages:[{
 *          base_page_id: 1,
 *          thumb: BASE_IP + '/images/page01.png',
 *          page_index: 0,
 *          content: []
 *       }]
*/
ItbPageModel.prototype.savePages = function(callback,doc_id,user_type,update_by,arrPageJson){
    var asyncFuncs = [];
    for (var i in arrPageJson) {

        asyncFuncs.push((function (index, pageJson) {
            return function (asyncCallback) {
                var entity = new ItbPageModel({
                    doc_id: doc_id,
                    user_type: user_type,
                    update_by: update_by,
                    replaces: JSON.stringify(pageJson.content),
                    page_index: pageJson.page_index,
                    base_page_id: pageJson.base_page_id,
                    dirty: Number(pageJson.dirty || "0")
                    //thumb_s:"http://7xogoq.com1.z0.glb.clouddn.com/FlKM8V-p9oSvFDZ9LkQ5Dzcn0GKH" // TODO 测试用
                });
                entity.saveToDB(function(error, newId){
                    if(error){
                        console.log('ItbPageModel.js [savePages] saveToDB error: '+error);
                    }
                    var ret = {page_index: pageJson.page_index, page_id: newId};
                    asyncCallback(null, ret);
                });
            }
        })(i, arrPageJson[i])); // 利用闭包解决动态参数传递问题
    }
    async.parallel(asyncFuncs, function (err, results) {
        var ret = results.sort(function(a,b){
            return a.page_index - b.page_index;
        });
        var retIds = [];
        for (var i in ret){
            retIds.push(ret[i].page_id);
        }
        callback(err, retIds);
    });
}
//------------------------------------------------------------------
// arrReplaceData: JSON字符串数组
/**
 * 批量新规/更新pages
 * @param callback
 * @param doc_id
 * @param user_type
 * @param user_id
 * @param arrPageJson:
 *       pages:[{
 *          page_id: 1, // 为空或<=0时新规,大于0时更新
 *          base_page_id: 1,
 *          thumb: BASE_IP + '/images/page01.png',
 *          page_index: 0,
 *          content: []
 *       }]
 */
ItbPageModel.prototype.updatePages = function(callback,doc_id,user_type,update_by,arrPageJson){
    var asyncFuncs = [];
    for (var i in arrPageJson) {

        asyncFuncs.push((function (index, pageJson) {
            return function (asyncCallback) {
                if (Number(pageJson.page_id || '0') <= 0) {
                    // 新规
                    var entity = new ItbPageModel({
                        doc_id: doc_id,
                        user_type: user_type,
                        update_by: update_by,
                        replaces: JSON.stringify(pageJson.content),
                        page_index: pageJson.page_index,
                        base_page_id: pageJson.base_page_id,
                        dirty: Number(pageJson.dirty || "0"),
                        //thumb_s:"xxx" // TODO
                    });
                    entity.saveToDB(function(error, newId){
                        if(error){
                            console.log('ItbPageModel.js [updatePages] saveToDB error: '+error);
                        }
                        var ret = {page_index: pageJson.page_index, page_id: newId};
                        asyncCallback(null, ret);
                    });
                } else {
                    // 更新
                    var updEnt = new ItbPageModel({
                        page_id: pageJson.page_id,
                        //doc_id: doc_id,
                        user_type: user_type,
                        update_by: update_by,
                        replaces: JSON.stringify(pageJson.content),
                        page_index: pageJson.page_index,
                        //base_page_id: pageJson.base_page_id,
                        dirty: Number(pageJson.dirty || "0"),
                        del_flg: 0,// 更新时恢复删除状态
                        thumb_s:'',// 更新为空,以便图片服务器重新生成
                    });
                    updEnt.updateToDB(function(error2, ret){
                        if(error2){
                            console.log('ItbPageModel.js [updatePages] updateToDB error: '+error2);
                        }
                        var ret = {page_index: pageJson.page_index, page_id: pageJson.page_id};
                        asyncCallback(null, ret);
                    });
                }
            }
        })(i, arrPageJson[i])); // 利用闭包解决动态参数传递问题
    }
    async.parallel(asyncFuncs, function (err, results) {
        var ret = results.sort(function(a,b){
            return a.page_index - b.page_index;
        });
        var retIds = [];
        for (var i in ret){
            retIds.push(ret[i].page_id);
        }
        callback(err, retIds);
    });
}

//------------------------------------------------------------------
/**
 * 将用户page的的base_page_id替换为模版页的id
 * @param callback
 * @param pages:[{
 *          base_page_id: 1,
 *          thumb: BASE_IP + '/images/page01.png',
 *          page_index: 0,
 *          content: []
 *       }]
 */
ItbPageModel.prototype.replateTemplatePageIdToUserPage = function(callback,pages){
    // 向上找一层即可
    var asyncFuncs = [];
    for (var i in pages) {
        asyncFuncs.push((function (index, page) {
            return function (asyncCallback) {
                var entity = new ItbPageModel({
                    page_id: page.base_page_id
                });
                entity.findFromDB(function(error, items) {
                   if(items && items.length>0 && items[0].base_page_id){
                       // 如果存在就修正，不存在说明page是模版页不需要修正
                       page.base_page_id = items[0].base_page_id;
                   }
                    asyncCallback(error,null);
                });
            }
        })(i, pages[i])); // 利用闭包解决动态参数传递问题
    }
    async.parallel(asyncFuncs, function (err, results) {
        callback(err);
    });
}

//------------------------------------------------------------------
/* 查询出“用户文档页”对应的“模版页数据”和“用户可替换数据”
 * 参数:user_doc_id:用户doc id
 * 参数:callback:回调，参数
 *          error:错误,null表示无错误
 *          pageModels:页面数据数组,每个元素为：
 *                  ItbPageModel结构
 *                  tmp_page_thumb_s［模版页的缩略图］
 * */
ItbPageModel.prototype.getUserPagesCombineTemplateByUserDocId=function(user_doc_id,callback){
    var THIS = this;
    var tableName = this.getTableName();

    pool.pool.getConnection(function(err, connection) {
        if (err) {
            console.log('ItbPageModel.getUserPagesCombineTemplateByUserDocId Err:'+err);
        }
        // Use the connection
        var sql =
            ' select p2.`page_id`,p2.`page_index`,p1.data,p2.`replaces`,p1.`thumb_s` as tmp_page_thumb_s '+
            ' from itb_tmpl_page p1 ,( '+ // itb_page --> itb_tmpl_page TODO
                ' select p.`page_id`,p.`base_page_id`,p.`data`,p.`replaces`,p.`page_index` '+
                ' from itb_page p '+
                ' where p.`doc_id`='+user_doc_id+
                ' and p.user_type=1 '+
                ' and p.`del_flg`=0 '+
                ' order by p.`page_index`) p2 '+
            ' where p1.`page_id`=p2.`base_page_id` '+
            ' order by page_index ';

        //var sqlValue = [];
        //var sql = mysql.format(sql, sqlValue);
        console.log(sql);
        connection.query(sql, function(error, result) {
            // And done with the connection.
            connection.release();

            console.log();

            callback(error, result);
        });
    });
}

//------------------------------------------------------------------
// 复制pages数据(贺卡用)
// callback 回调
ItbPageModel.prototype.copyPagesByDocIdForCard = function(callback){
    var THIS = this;

    pool.pool.getConnection(function(err, connection) {
        // Use the connection
        // 第一页thumb_s设空，复制replaces
        var sql =
            " INSERT INTO itb_page " +
            " (doc_id, base_page_id, page_index, user_type, " +
            " replaces, thumb_s, video, create_time, update_time, update_by, del_flg) " +
            " SELECT ?, page_id, page_index, 1, " +
            " CASE WHEN page_index=0 THEN replaces ELSE '[]' END, " +
            " CASE WHEN page_index=0 THEN null ELSE thumb_s END, '[]', sysdate(), sysdate(), 0, 0 " +
            " FROM itb_tmpl_page WHERE tmpl_id=? and del_flg=0 ";
        var sqlValue = [ THIS.docId, THIS.templateId ];
        var sql = mysql.format(sql, sqlValue);
        console.log(sql);
        connection.query(sql, function(error, result) {
            // And done with the connection.
            connection.release();

            if (error)
                console.log(error);

            callback(error);
        });
    });

}

//------------------------------------------------------------------
// 复制pages数据(娱乐用)
// callback 回调
ItbPageModel.prototype.copyPagesByDocIdForEnt = function(callback){
    var THIS = this;

    pool.pool.getConnection(function(err, connection) {
        // Use the connection
        // thumb_s设空，复制replaces
        var sql =
            " INSERT INTO itb_page " +
            " (doc_id, base_page_id, page_index, user_type, " +
            " replaces, thumb_s, video, create_time, update_time, update_by, del_flg) " +
            " SELECT ?, page_id, page_index, 1, " +
            " replaces, null, '[]', sysdate(), sysdate(), 0, 0 " +
            " FROM itb_tmpl_page WHERE tmpl_id=? and del_flg=0 ";
        var sqlValue = [ THIS.docId, THIS.templateId ];
        var sql = mysql.format(sql, sqlValue);
        console.log(sql);
        connection.query(sql, function(error, result) {
            // And done with the connection.
            connection.release();

            if (error)
                console.log(error);

            callback(error);
        });
    });
}

//------------------------------------------------------------------
/* 更新replaces和video信息(贺卡用)
 */
ItbPageModel.prototype.updateForCard = function(callback){
    var THIS = this;

    pool.pool.getConnection(function(err, connection) {
        // Use the connection

        var sql = " UPDATE itb_page ";
        if (THIS.replaces){
            sql += " SET replaces=? WHERE page_id=? ";
            var sqlValue = [THIS.replaces, THIS.page_id];
            sql = mysql.format(sql, sqlValue);
        } else if (THIS.video){
            sql += " SET video=? WHERE page_id=? ";
            var sqlValue = [THIS.video, THIS.page_id];
            sql = mysql.format(sql, sqlValue);
        }

        console.log(sql);
        connection.query(sql, function(error, result) {
            // And done with the connection.
            connection.release();

            console.log();

            callback(error, result);
        });
    });
}

//------------------------------------------------------------------
/* 查询指定文档的page信息及其来源模版的replace信息 TODO
 * 参数:doc_id: 文档id
 * 参数:page_id: 文档页id(可选)
 * 参数:callback:回调，参数
 * */
ItbPageModel.prototype.getPageInfoAndTmplRep=function(callback){
    var THIS = this;
    var tableName = this.getTableName();

    pool.pool.getConnection(function(err, connection) {
        if (err) {
            console.log('ItbPageModel.getPageInfoAndTmplRep Err:'+err);
        }
        // Use the connection
        var sql = ' SELECT t.*, t2.page_id AS tmpl_page_id, t2.replaces AS tmpl_replaces, t2.thumb_s AS tmpl_thumb ' +
            ' FROM itb_page t ' +
            ' LEFT JOIN itb_tmpl_page t2 ' +
            ' ON t.base_page_id = t2.page_id AND t2.del_flg = 0 ';
        if (THIS.tmpl_id) {
            sql += ' AND t2.tmpl_id = ' + THIS.tmpl_id;
        }
        sql +=  ' WHERE t.del_flg = 0 ';
        if (THIS.doc_id) {
            sql += ' AND t.doc_id = ' + THIS.doc_id;
        }
        if (THIS.page_id) {
            sql += ' AND t.page_id = ' + THIS.page_id;
        }
        sql += ' ORDER BY t.page_index ';

        //var sqlValue = [];
        //var sql = mysql.format(sql, sqlValue);
        console.log(sql);
        connection.query(sql, function(error, result) {
            // And done with the connection.
            connection.release();

            console.log();

            callback(error, result);
        });
    });
}

//------------------------------------------------------------------
/* 根据文档页id更新base_page_id,replaces信息(可多页更新)
 注意:需要初始化 updData =
 [{
    page_id: 122,
    base_page_id: xxx,
    replaces: yyy
 }]
 */
ItbPageModel.prototype.updatePagesReplaces = function(callback){
    var THIS = this;
    var arrData = THIS.updData;

    pool.pool.getConnection(function(err, connection) {
        var asyncFuncs = [];
        for (var i in arrData) {

            asyncFuncs.push((function (index, data) {
                return function (asyncCallback) {

                    var sql=" UPDATE ITB_PAGE SET update_time=sysdate(), base_page_id=?, replaces=?, thumb_s=null WHERE page_id=? ";
                    var param=[data.base_page_id, data.replaces, data.page_id];

                    var exeSql = mysql.format(sql, param);
                    console.log(exeSql);
                    connection.query(exeSql, function (error, result) {

                        if (error) {
                            console.log('ItbPageModel.js [updatePagesReplaces] upd err: ' + error);
                        }

                        asyncCallback(error, result);
                    });
                }
            })(i, arrData[i])); // 利用闭包解决动态参数传递问题
        }
        async.parallel(asyncFuncs, function (err, results) {

            // And done with the connection.
            connection.release();

            callback(err, results);
        });
    });
}

// 导出
module.exports = ItbPageModel;